import logging

from flickrsearch.lib.base import *
import flickrsearch.lib.flickr as flickr

from pylons import request
from pylons import tmpl_context as c
from pylons.templating import render_mako as render

log = logging.getLogger(__name__)

flickr.API_KEY = "Your key here"

class FlickrController(BaseController):

    def index(self):
        return render('/flickr.mako')

    def search(self):
        photos = flickr.photos_search(tags=request.params['tags'], per_page=24)
        c.photos = [photo.getURL(size="Small", urlType='source') for photo in photos]
        return render('/photos.mako')
